var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var a = t("ConfS"),
    i = cc._decorator,
    s = i.ccclass,
    c = i.property,
    l = (function (t) {
        function e() {
            var e = (null !== t && t.apply(this, arguments)) || this;
            return (e.v2 = cc.v2()), (e.yoffset = 100), (e.camera = null), (e.bg = null), (e.player = null), e;
        }
        return (
            n(e, t),
            (e.prototype.onEnable = function () {
                (this.v2.x = a.DatasManager.触发屏幕移动点[0]), (this.v2.y = a.DatasManager.触发屏幕移动点[1]);
            }),
            (e.prototype.update = function () {
                var t = this.player.x,
                    e = this.player.y + this.yoffset,
                    o = Math.abs(t - this.camera.x),
                    n = Math.abs(e - this.camera.y);
                if (o > this.v2.x) {
                    var r = o - this.v2.x;
                    t > this.camera.x ? (this.camera.x += r) : (this.camera.x -= r);
                }
                if (n > this.v2.y) {
                    r = n - this.v2.y;
                    e > this.camera.y ? (this.camera.y += r) : (this.camera.y -= r);
                }
                var a = cc.Canvas.instance.node.width / 2,
                    i = this.camera.x - a,
                    s = -this.bg.width / 2;
                if (s > i) {
                    var c = s - i;
                    this.camera.x += c;
                } else {
                    var l = this.camera.x + a,
                        u = this.bg.width / 2;
                    if (l > u) {
                        c = l - u;
                        this.camera.x -= c;
                    }
                }
                var p = cc.Canvas.instance.node.height / 2,
                    f = this.camera.y + p,
                    d = this.bg.height / 2;
                if (f > d) {
                    c = f - d;
                    this.camera.y -= c;
                } else {
                    var h = this.camera.y - p,
                        y = -this.bg.height / 2;
                    if (y > h) {
                        c = y - h;
                        this.camera.y += c;
                    }
                }
            }),
            r([c], e.prototype, "yoffset", void 0),
            r([c(cc.Node)], e.prototype, "camera", void 0),
            r([c(cc.Node)], e.prototype, "bg", void 0),
            r([c(cc.Node)], e.prototype, "player", void 0),
            (e = r([s], e))
        );
    })(cc.Component);
o.default = l;
